import 'package:wallet/entity/quotation_entity.dart';

quotationEntityFromJson(QuotationEntity data, Map<String, dynamic> json) {
	if (json['data'] != null) {
		data.data = new List<QuotationData>();
		(json['data'] as List).forEach((v) {
			data.data.add(new QuotationData().fromJson(v));
		});
	}
	if (json['maxpage'] != null) {
		data.maxpage = json['maxpage']?.toInt();
	}
	if (json['currpage'] != null) {
		data.currpage = json['currpage']?.toInt();
	}
	if (json['code'] != null) {
		data.code = json['code']?.toInt();
	}
	if (json['msg'] != null) {
		data.msg = json['msg']?.toString();
	}
	return data;
}

Map<String, dynamic> quotationEntityToJson(QuotationEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.data != null) {
		data['data'] =  entity.data.map((v) => v.toJson()).toList();
	}
	data['maxpage'] = entity.maxpage;
	data['currpage'] = entity.currpage;
	data['code'] = entity.code;
	data['msg'] = entity.msg;
	return data;
}

quotationDataFromJson(QuotationData data, Map<String, dynamic> json) {
	if (json['current_price'] != null) {
		data.currentPrice = json['current_price']?.toDouble();
	}
	if (json['current_price_usd'] != null) {
		data.currentPriceUsd = json['current_price_usd']?.toDouble();
	}
	if (json['code'] != null) {
		data.code = json['code']?.toString();
	}
	if (json['name'] != null) {
		data.name = json['name']?.toString();
	}
	if (json['fullname'] != null) {
		data.fullname = json['fullname']?.toString();
	}
	if (json['logo'] != null) {
		data.logo = json['logo']?.toString();
	}
	if (json['change_percent'] != null) {
		data.changePercent = json['change_percent']?.toDouble();
	}
	if (json['market_value'] != null) {
		data.marketValue = json['market_value']?.toDouble();
	}
	if (json['vol'] != null) {
		data.vol = json['vol']?.toDouble();
	}
	if (json['supply'] != null) {
		data.supply = json['supply']?.toDouble();
	}
	if (json['rank'] != null) {
		data.rank = json['rank']?.toInt();
	}
	if (json['star_level'] != null) {
		data.starLevel = json['star_level']?.toInt();
	}
	if (json['kline_data'] != null) {
		data.klineData = json['kline_data']?.toString();
	}
	if (json['market_value_usd'] != null) {
		data.marketValueUsd = json['market_value_usd']?.toDouble();
	}
	if (json['vol_usd'] != null) {
		data.volUsd = json['vol_usd']?.toDouble();
	}
	if (json['marketcap'] != null) {
		data.marketcap = json['marketcap']?.toDouble();
	}
	if (json['high_price'] != null) {
		data.highPrice = json['high_price']?.toDouble();
	}
	if (json['drop_ath'] != null) {
		data.dropAth = json['drop_ath']?.toDouble();
	}
	if (json['low_price'] != null) {
		data.lowPrice = json['low_price']?.toDouble();
	}
	if (json['high_time'] != null) {
		data.highTime = json['high_time']?.toString();
	}
	if (json['low_time'] != null) {
		data.lowTime = json['low_time']?.toString();
	}
	if (json['isifo'] != null) {
		data.isifo = json['isifo']?.toInt();
	}
	if (json['ismineable'] != null) {
		data.ismineable = json['ismineable']?.toInt();
	}
	if (json['ads'] != null) {
		data.ads = json['ads']?.map((v) => v?.toString())?.toList()?.cast<String>();
	}
	if (json['adpairs'] != null) {
		data.adpairs = json['adpairs']?.map((v) => v?.toString())?.toList()?.cast<String>();
	}
	if (json['turnoverrate'] != null) {
		data.turnoverrate = json['turnoverrate']?.toDouble();
	}
	if (json['changerate_utc'] != null) {
		data.changerateUtc = json['changerate_utc']?.toDouble();
	}
	if (json['changerate_utc8'] != null) {
		data.changerateUtc8 = json['changerate_utc8']?.toDouble();
	}
	return data;
}

Map<String, dynamic> quotationDataToJson(QuotationData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['current_price'] = entity.currentPrice;
	data['current_price_usd'] = entity.currentPriceUsd;
	data['code'] = entity.code;
	data['name'] = entity.name;
	data['fullname'] = entity.fullname;
	data['logo'] = entity.logo;
	data['change_percent'] = entity.changePercent;
	data['market_value'] = entity.marketValue;
	data['vol'] = entity.vol;
	data['supply'] = entity.supply;
	data['rank'] = entity.rank;
	data['star_level'] = entity.starLevel;
	data['kline_data'] = entity.klineData;
	data['market_value_usd'] = entity.marketValueUsd;
	data['vol_usd'] = entity.volUsd;
	data['marketcap'] = entity.marketcap;
	data['high_price'] = entity.highPrice;
	data['drop_ath'] = entity.dropAth;
	data['low_price'] = entity.lowPrice;
	data['high_time'] = entity.highTime;
	data['low_time'] = entity.lowTime;
	data['isifo'] = entity.isifo;
	data['ismineable'] = entity.ismineable;
	data['ads'] = entity.ads;
	data['adpairs'] = entity.adpairs;
	data['turnoverrate'] = entity.turnoverrate;
	data['changerate_utc'] = entity.changerateUtc;
	data['changerate_utc8'] = entity.changerateUtc8;
	return data;
}